<?php
unset($_GET['ok']);
$sort1=isset($_GET['sort'])?'&sort='.$_GET['sort']:'';
$cs=Yii::app()->clientScript;
$cs->registerScript('mandatory_maintenance_excel',<<<END
$("#excel").click(
function(){
	var act=$("form").attr('action');
	$("form").attr('action',act+'&excel=1$sort1').attr('target','_blank').submit().attr('action',act).attr('target','');
}
);
END
);
?>
<?php if($search):?>
<h2>查询车辆/尾板营运证强制保养信息</h2>
<?php else:?>
<h2>修改车辆/尾板营运证强制保养信息</h2>
<?php endif?>
<?php echo CHtml::beginForm(array($search?'search':'admin'),'post');?>
<table  style="margin: 0 auto;"  width="960">
<tr><td>
	车辆/尾板：<?php echo CHtml::dropDownList('keys[mandatory_maintenance.kind]', isset($_GET['keys']['mandatory_maintenance.kind'])?$_GET['keys']['mandatory_maintenance.kind']:'', array(''=>'全部','0'=>'车辆','1'=>'尾板'));?>
	车辆/尾板牌号：<input type="text" name="keys[trucks.plate_no]" size="7" value="<?php echo isset($_GET['keys']['trucks.plate_no'])?$_GET['keys']['trucks.plate_no']:'';?>"/>
	模糊查询：<?php echo CHtml::radioButtonList('keys[blur]',isset($_GET['keys']['blur'])?$_GET['keys']['blur']:'1', array('1'=>'是','0'=>'否'),array('separator'=>''));?>
	保养日期：从<input type="text" id="keys[s_date]" name="keys[s_date]" size="7" value="<?php echo isset($_GET['keys']['s_date'])?$_GET['keys']['s_date']:'';?>"/>
	<?php $this->widget('application.extensions.calendar.SCalendar',array('inputField'=>'keys[s_date]','ifFormat'=>'%Y-%m-%d'));?>
	至<input type="text" id="keys[e_date]" name="keys[e_date]" size="7" value="<?php echo isset($_GET['keys']['e_date'])?$_GET['keys']['e_date']:'';?>"/>
	<?php $this->widget('application.extensions.calendar.SCalendar',array('inputField'=>'keys[e_date]','ifFormat'=>'%Y-%m-%d'));?>
	下次保养日期：从<input type="text" id="keys[n_s_date]" name="keys[n_s_date]" size="7" value="<?php echo isset($_GET['keys']['n_s_date'])?$_GET['keys']['n_s_date']:'';?>"/>
	<?php $this->widget('application.extensions.calendar.SCalendar',array('inputField'=>'keys[n_s_date]','ifFormat'=>'%Y-%m-%d'));?>
	至<input type="text" id="keys[n_e_date]" name="keys[n_e_date]" size="7" value="<?php echo isset($_GET['keys']['n_e_date'])?$_GET['keys']['n_e_date']:'';?>"/>
	<?php $this->widget('application.extensions.calendar.SCalendar',array('inputField'=>'keys[n_e_date]','ifFormat'=>'%Y-%m-%d'));?>
	<input type="submit" value="搜索"/>&nbsp;&nbsp;&nbsp;&nbsp;<input id="excel" type="button" value="输出excel文件"/>
</td></tr></table>
<?php echo CHtml::endForm();?>
<table class="dataGrid" width="960">
  <thead>
  <tr>
   	<th width="100"><?php echo $sort->link('plate_no'); ?></th>
  	<th width="100"><?php echo $sort->link('property_owner'); ?></th>
  	<th width="70"><?php echo $sort->link('kind'); ?></th>
    <th width="100"><?php echo $sort->link('mm_date'); ?></th>
    <th width="120"><?php echo $sort->link('next_mm_date'); ?></th>
    <th width="90"><?php echo $sort->link('mm_cost'); ?></th>
    <th width="90"><?php echo $sort->link('other_cost'); ?></th>
    <th width="70"><?php echo $sort->link('total_cost'); ?></th>
    <th width="110"><?php echo $sort->link('create_time'); ?></th>
	<?php if(!$search):?><th width="70">操作</th><?php endif ?>
  </tr>
  </thead>
  <tbody>
<?php foreach($models as $n=>$model): ?>
  <tr class="<?php echo $n%2?'even':'odd';?>">
    <?php 
    	$url=array('show','id'=>$model->id)+$_GET;//把所有参数包括页码、查询参数传入显示信息页面
    	$url['ret']=$search?'search':'admin';
    ?>
    <td><?php echo CHtml::link($model->plate_no,$url); ?></td>
    <td><?php echo CHtml::encode($model->property_owner); ?></td>
    <td><?php echo CHtml::encode($model->getKindName()); ?></td>
    <td><?php echo CHtml::encode($model->mm_date); ?></td>
    <td><?php echo CHtml::encode($model->next_mm_date); ?></td>
    <td><?php echo CHtml::encode($model->mm_cost); ?></td>
    <td><?php echo CHtml::encode($model->other_cost); ?></td>
    <td><?php echo CHtml::encode($model->total_cost); ?></td>
    <td><?php echo CHtml::encode($model->create_time); ?></td>
    <?php if(!$search):?>
    <td>
      <?php echo CHtml::link('修改',array('update','id'=>$model->id)+$_GET); ?>
     <?php echo CHtml::link('删除',array('delete','id'=>$model->id)+$_GET,array('confirm'=>"确定要删除牌号:".$model->plate_no."的".($model->kind==0?'车辆':'尾板')."营运证强制保养信息吗？")); ?>
	</td>
	<?php endif ?>
  </tr>
<?php endforeach; ?>
  </tbody>
</table>
<br/>
<?php $this->widget('CLinkPager',array('pages'=>$pages,'htmlOptions'=>array('style'=>'width:960px;'))); ?>